package activiti.day04;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: 蔡翔
 * @Date: 2019/9/5 13:25
 * @Version 1.0
 * 启动流程实例：动态设置 assignee
 */
public class AssigneeUEL {
    public static void main(String[] args) {
        /**
         *1.得到ProcessEngine对象
         **/
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

        /**
         *2.得到RuntimeService对象，，得到正在跑的实例。
         **/
        RuntimeService runtimeService = processEngine.getRuntimeService();

        /**
         *3.设置assignee的取值 ，， 用户在界面上设置流程的执行人
         **/
        Map<String,Object> map = new HashMap<>();
        map.put("assignee0","zhangsan");
        map.put("assignee1","lishi");
        map.put("assignee2","wangwu");

        /**
         *4.启动流程实例，同时还要设置流程定义的assignee的值
         * 只要把map穿进去就行了。它会自动的解析 ${assignee0} ==> zhangsan
         **/
        runtimeService.startProcessInstanceByKey("holiday",map);

        /**
         * 5.输出
         **/
        System.out.println(processEngine.getName());
    }
}
